//
//  CalorieJsonModel.swift
//  UIScrollView的快速使用
//
//  Created by hongfei tam on 2019/6/25.
//  Copyright © 2019 YQ05. All rights reserved.
//

import Foundation

// MARK: - Welcome
struct Welcome: Codable {
    let isFood: Bool
    let lang: String
    let results: [Result]
    
    enum CodingKeys: String, CodingKey {
        case isFood = "is_food"
        case lang, results
    }
}

// MARK: - Result
struct Result: Codable {
    let items: [Item]
    let group: String
}

// MARK: - Item
struct Item: Codable {
    let servingSizes: [ServingSize]
    let score: Int
    let nutrition: Nutrition
    let name, foodID, group: String
    let generic: Bool?
    
    enum CodingKeys: String, CodingKey {
        case servingSizes, score, nutrition, name
        case foodID = "food_id"
        case group, generic
    }
}

// MARK: - Nutrition
struct Nutrition: Codable {
    let totalCarbs, totalFat: Double?
    let protein, calories: Double
}

// MARK: - ServingSize
struct ServingSize: Codable {
    let unit: String
    let servingWeight: Double?
}
